﻿using HZH_Controls.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HZH_Controls.Forms;
using 渐变.common;
using 渐变.model;

namespace 渐变
{
    public partial class welcomeForm : Form
    {
        public welcomeForm()
        {
            InitializeComponent();
        }

        private void HomePanel_Paint(object sender, PaintEventArgs e)
        {

        }
        public void loadMsg()
        {
            List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "title", Width = 30, WidthType = SizeType.Percent });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "createtime", Width = 50, WidthType = SizeType.Percent });

            this.ucDataGridView1.Columns = lstCulumns;
            //this.ucDataGridView1.IsShowCheckBox = true;
            string sql = "select * from notice";
            DataTable dt = DBHelper.ExecuteQuery(sql);
            ModelHandler<model.notice> mconvert = new common.ModelHandler<model.notice>();
            var list = mconvert.FillModel(dt);

            this.ucDataGridView1.DataSource = list;
            //this.ucDataGridView1.First();
            //设置是否允许自动生成列
           
        }
        private void welcomeForm_Load(object sender, EventArgs e)
        {
            this.Dock = DockStyle.Fill;
            loadMsg();
        }

        private void ucDataGridView1_ItemClick(object sender, DataGridViewEventArgs e)
        {
            var row = ucDataGridView1.SelectRow;
            if (row.DataSource !=null)
            {
                var model = (row.DataSource as notice);
                FrmNotice frm = new FrmNotice(model);
                frm.StartPosition = FormStartPosition.CenterParent;
                frm.ShowDialog(this);
                //弹出层
                //FrmWithTitle frm = new FrmWithTitle();
                //frm.Show();
            }
        }
    }
}
